package com.banyuan.HomeWork.string;
//统计字符串“abcdefgabdcdefgabcddefg”里有多少个字符‘d’；
public class seven {
    public static void main(String[] args) {
        String s1 ="abcdefgabdcdefgabcddefg";
        String[] arr1 = s1.split("d");
        String s2 = "";
        for (String s : arr1) {
            s2 = s2 + s;
        }
        System.out.println("字符串“abcdefgabdcdefgabcddefg”里有" + (s1.length() - s2.length()) + "个字符'd'");

        //利用for循环和charAt判断
    }
}
